
<%@ page import="org.xilin.Course" %>

<g:setProvider library="jquery"/>

<div>
    <g:if test="${flash.message}">
      <div class="message" style="display:none">${flash.message}</div>
    </g:if>
  
    <g:hasErrors bean="${courseInstance}">
      <div class="errors" style="display:block">
          <g:renderErrors bean="${courseInstance}" as="list" />
      </div>
    </g:hasErrors>
    <g:formRemote name="saveCourse" url="${[action:'save']}" method="post" update="cluetip-inner" before="beforeSave()" onComplete="processResponse()">
        <g:hiddenField name="view" value="create" />
        <g:hiddenField name="id" value="${courseInstance.id}" />
        <div class="dialog">
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="name"><g:message code="course.name.label" default="Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'name', 'errors')}">
                            <g:textField name="name" value="${courseInstance?.name}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="capacity"><g:message code="course.capacity.label" default="Capacity" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'capacity', 'errors')}">
                            <g:textField name="capacity" value="${fieldValue(bean: courseInstance, field: 'capacity')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="regCapacity"><g:message code="course.regCapacity.label" default="Reg Capacity" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'regCapacity', 'errors')}">
                            <g:textField name="regCapacity" value="${fieldValue(bean: courseInstance, field: 'regCapacity')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="price"><g:message code="course.price.label" default="Price" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'price', 'errors')}">
                            <g:textField name="price" value="${fieldValue(bean: courseInstance, field: 'price')}" />
                        </td>
                    </tr>
                
                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="startTime"><g:message code="course.startTime.label" default="Start Time" /></label>
                        </td>
                        <td valign="top" class="value">
                            <g:textField name="startTime" maxlength="8" value="${courseInstance?.startTime}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="endTime"><g:message code="course.endTime.label" default="End Time" /></label>
                        </td>
                        <td valign="top" class="value">
                            <g:textField name="endTime" maxlength="8" value="${courseInstance?.endTime}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="status"><g:message code="course.status.label" default="Active" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'status', 'errors')}">
                            <g:checkBox name="status" value="${courseInstance?.status}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="desc1"><g:message code="course.desc1.label" default="Desc1" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'desc1', 'errors')}">
                            <g:textField name="desc1" value="${courseInstance?.desc1}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="desc2"><g:message code="course.desc2.label" default="Desc2" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'desc2', 'errors')}">
                            <g:textField name="desc2" value="${courseInstance?.desc2}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="grade"><g:message code="course.grade.label" default="Grade" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'grade', 'errors')}">
                            <g:textField name="grade" value="${courseInstance?.grade}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="classRoom.id"><g:message code="course.classRoom.label" default="Class Room" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'classRoom', 'errors')}">
                            <g:select name="classRoom.id" from="${org.xilin.RoomSchedule.list()}" optionKey="id" value="${courseInstance?.classRoom?.id}"  />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="category"><g:message code="course.category.label" default="Category" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'category', 'errors')}">
                            <g:select name="category" from="${courseInstance.categories}" value="${courseInstance?.category}"/>
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="teacher.id"><g:message code="course.teacher.label" default="Teacher" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'teacher', 'errors')}">
                            <g:select name="teacher.id" from="${org.xilin.Teacher.list()}" optionKey="id" value="${courseInstance?.teacher?.id}"  />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="book.id"><g:message code="course.book.label" default="Book" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'book', 'errors')}">
                            <g:select name="book.id" from="${org.xilin.Book.list()}" optionKey="id" value="${courseInstance?.book?.id}"  />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="semester.id"><g:message code="course.semester.label" default="Semester" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: courseInstance, field: 'semester', 'errors')}">
                            <g:select name="semester.id" from="${org.xilin.Semester.list()}" optionKey="id" value="${courseInstance?.semester?.id}"  />
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <br/>
        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Save')}" /></span>
            <span class="button"><input type="reset" value="${message(code: 'default.button.clear.label', default: 'Reset')}" /></span>
        </div>
    </g:formRemote>
</div>
